package com.xiaoma.myaudience.biz.activity;

import cn.jpush.android.api.JPushInterface;

import com.xiaoma.myaudience.util.activity.BaseActivity;
import com.xiaoma.myaudience.R;

import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ToggleButton;

/**
 * @author st.Wang
 * @description 推送通知开关
 */
public class MyPushServiceSwitchActivity extends BaseActivity implements OnCheckedChangeListener {
	private static Boolean b;
	private ToggleButton mToggleButton;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.personal_pushservice_activity);
        mToggleButton =(ToggleButton)findViewById(R.id.toggleButton1);
        if(b==null){
            b = mToggleButton.isChecked();
        }else{
        	mToggleButton.setChecked(b);
        }

        mToggleButton.setOnCheckedChangeListener(this);
	}
	@Override
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		// TODO Auto-generated method stub
		b = isChecked;
		mToggleButton.setChecked(b);
		if(isChecked){
			JPushInterface.resumePush(getApplicationContext());
		}else{
			JPushInterface.stopPush(getApplicationContext());
		}
	}
}
